#ifndef JOLFS_CONFIGURATION_H
#define JOLFS_CONFIGURATION_H

#include <string>
#include <vector>
#include <list>

namespace jolfs
{

class Configuration
{
public:
  class Node
  {
  public:
    enum Type
    {
      LOCAL,
      REMOTE
    };
    
  public:
    Node();
    Node( const Node& );
    Node( Type type, const std::string& source );
    ~Node();
    
  public:
    bool operator==( const Node& );
    
  public:
    Type               getType()   const;
    const std::string& getSource() const;
    
    void setType  ( Type               );
    void setSource( const std::string& );
    
  private:
    Type        type_;
    std::string source_;
  };
  
  class Volume
  {
  public:
    static const Node* NO_NODE;
    
  public:
    enum Link
    {
      MERGE,
      REPLICATE
    };
    
    typedef std::list<Volume*> VolumeList;
    
  public:
    Volume();
    Volume( const Volume& );
    Volume( const std::string& name, Link link, const Node* node );
    ~Volume();
    
  public:
    bool operator==( const Volume& );
    
  public:
    const std::string& getName()    const;
    const VolumeList&  getVolumes() const;
    Link               getLink()    const;
    const Node*        getNode()    const;
    
  public:
    void setName  ( const std::string& );
    void addVolume( Volume*            );
    void delVolume( Volume*            );
    void setLink  ( Link               );
    void setNode  ( const Node*        );
    
  private:
    std::string name_;
    VolumeList  volumes_;
    Link        link_;
    const Node* node_;
  };
  
public:
  typedef std::list<Node*> NodeList;
  
public:
  Configuration();
  Configuration( const Configuration& );
  ~Configuration();
  
public:
  const NodeList& getNodes()       const;
  const Volume&   getMountVolume() const;
  Volume&         getMountVolume();
  
  void addNode( Node*       );
  void delNode( const Node* );
  
private:
  NodeList nodes_;
  Volume   mountVolume_;
};

} // namespace jolfs

#endif // JOLFS_CONFIGURATION_H
